﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.Configuration;

namespace NRemedy.CodeGenerator.WinForm
{
    public class ARThread
    {
        protected virtual IARServer _server { get; set; }
        protected virtual Thread _thread { get; set; }

        protected virtual ARLoginContext _context { get; set; }

        private static readonly string ARServer = ConfigurationManager.AppSettings["ARServer"];
        private static readonly string ARUid = ConfigurationManager.AppSettings["ARUid"];
        private static readonly string ARPwd = ConfigurationManager.AppSettings["ARPwd"];


        public virtual ThreadState ThreadState
        {
            get { return this._thread.ThreadState; }
        }

        public ARThread()
        {
            _context = new ARLoginContext
            {
                Server = ARServer,
                User = ARUid,
                Password = ARPwd,
                Authentication = string.Empty
            };

        }

        public virtual bool IsRunning()
        {
            if (this._thread == null) return false;
            if (this._thread.ThreadState == System.Threading.ThreadState.Running) return true;
            return false;
        }
    }
}
